package com.test.demo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 跳过swagger
     */
    private final List<String> EXCLUDE_PATH_PATTERN_LIST = Arrays.asList("/v2/api-docs/**", "/swagger-resources/**", "/webjars/**", "/swagger-ui.html");

    @Autowired
    private Interceptor interceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor).addPathPatterns("/**").excludePathPatterns(EXCLUDE_PATH_PATTERN_LIST);
    }
}
